package com.commerceerp.system.api.winit;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;


public class QueryProductInventoryListHandler extends BaseHandler
{

    /**
     * 可以查询指定仓库的商品库存数据
     */
    @Test
    public void QueryProductInventoryList() {
        JSONObject data = new JSONObject();
        data.put("inventoryType", "Warehouse");
        //data.put("countryCode", "");
        data.put("warehouseId", "1000089");
        //data.put("warehouseCode", "USWC2");
        data.put("productCode", "");
        //data.put("specification", "");
        //data.put("inReturnInventory", "Y");
        //data.put("DOITier", "");
        //data.put("categoryID", "");
        //data.put("name", "");
        BaseHandler test = new BaseHandler();
        String result = test.doQuery("queryProductInventoryList4Page",data);
        JSONObject json = JSONObject.parseObject(result);
        JSONObject js  = (JSONObject)json.get("data");
        JSONArray array  = (JSONArray)js.get("list");
        List list = new ArrayList();
        for(int i=0;i<array.size();i++){
            JSONObject iObj=array.getJSONObject(i);
            String qtyAvailable=iObj.getString("qtyAvailable");
            if(!"0".equals(qtyAvailable)){
                list.add(qtyAvailable);
            }
            System.out.println(qtyAvailable);
        }
        System.out.println("list: " + list.toString());
    }
}
